// 引入管理列表接口
import { userList } from '@/request/api'

// 封装一个接口
interface StateUser {
    userlist: Array<object>
}

const state = {
    userlist: []
}

const getters = {
    getUser(state: StateUser) {
        return state.userlist
    }
}

const mutations = {
    REQ_USERLIST(state: StateUser, payload: any) {
        state.userlist = payload
    }
}

const actions = {
    getUserAction(context: any) {
        // 调用接口
        userList({
            size: 10,
            page: 1
        }).then(res => {
            context.commit('REQ_USERLIST', res.list)
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    // 命名空间
    namespaced: true
}